/* 
 * File:   SDRS.h
 * Author: liuyi
 *
 * Created on July 21, 2009, 10:58 AM
 */

#ifndef _SDRS_H
#define	_SDRS_H

#include "header.h"

#include <cstdlib>

#include <vector>
#include <string>

using namespace std;

/**
 * Subtitle Detection and Recognition System
 */
class SDRS {
public:
    /**
     * Detect subtile and keyword embeded in input grey image data
     *
     * @param greyData input grey image data
     * @param width the width of input image data
     * @param height the height of input image data
     *
     * @return  0 no subtitle detected
     *          1 detected subtitle, but no keyword
     *          2 found keywords in subtitle
     */
    static int detectKeyword(const uchar *greyData, int width, int height);

    /** init SDRS */
    static void init(const string &configFilePath);

    /** release SDRS */
    static void release();
    
private:
    static void retrieve(vector<ushort> &result, const uchar *greyData, int width, int height);

    static void retrieveInRegion(vector<ushort> &result, const uchar *greyData, int width, int height);

    static int findFirstIndex(const vector<ushort> &str, const vector<ushort> &sub);
    
    static vector<vector<ushort> *> m_keywordList;
    
    SDRS();
    ~SDRS();
    
};

#endif	/* _SDRS_H */

